package com.yt.controller;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.netflix.ribbon.proxy.annotation.Hystrix;
import com.yt.service.GetInfoFeign;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.UUID;

/**
 * @Classname OrderController
 * @Description
 * @Date 2021/10/20 19:42
 * @Create by 杨涛
 */
@RestController
@DefaultProperties(defaultFallback = "dofallback")
public class OrderController {


    @Resource
    GetInfoFeign getInfoFeign;


    @RequestMapping("/getinfook")
    public String getinfo_timeok() {
        return "comsumer 80 :" + getInfoFeign.getinfo_timeok();
    }

//    @HystrixCommand(fallbackMethod = "fallbackout", commandProperties = {
//            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1500")
//    })
    @HystrixCommand //有了默认配置就不用单独指定了
    @RequestMapping("/getinfoout")
    public String getinfo_timeout() {
        return "comsumer 80 :" + getInfoFeign.getinfo_timeout();
    }

    public String fallbackout() {
        return "Thread:" + Thread.currentThread().getName() + " consumer -fallback:" + UUID.randomUUID();
    }
    public String dofallback() {
        return "默认的熔断处理方法  Thread:" + Thread.currentThread().getName()  ;
    }
}
